package com.haoshuang.zhouzhoubang.ui.page.mine.contract.add

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class AddContractViewModel : BaseViewModel() {

    /**
     * 添加合同
     */
    val addContractData = StatefulMutableLiveData<Any>()
    fun addContract(start_time: String, end_time: String, contract_picture: String) = netRequest {
        start { addContractData.value = StateData.Loading }
        request { ApiRepo.addContract(start_time, end_time, contract_picture) }
        success { addContractData.value = StateData.Success(it.data) }
        error { code, msg ->
            addContractData.value = StateData.Error(code, msg)
        }
    }

}